#
# This uses $1, SQUEAK_VM_SVN, which must be a svn co argument
#   to checkout and build the squeak-vm tarball.
# $2, SQUEAK_VM_SOURCE, is used to check that the built tarball has
#   the same name as expected 
#

SQUEAK_VM_SVN=$1
SQUEAK_VM_SOURCE=$2

TMP=$(mktemp -d)

pushd $TMP
svn checkout ${SQUEAK_VM_SVN} squeak-vm-svn
cd squeak-vm-svn
./autogen.sh
cd bld
make dist-src
cd ../dist
if [ -e ${SQUEAK_VM_SOURCE} ]; then
   popd
   cp $TMP/squeak-vm-svn/dist/${SQUEAK_VM_SOURCE} .
   rm -rf $TMP
else
   echo "ERROR: ${SQUEAK_VM_SOURCE} was not built"
   echo "These were the Squeak tar.gz's actually built:"
   ls -1 Squeak-*.tar.gz
   echo "Not deleting $TMP/squeak-vm-svn" 
   exit 3
fi
